[WIP] Fix NPM detector to differentiate packages by namespace#1713
Open
[WIP] Fix NPM detector to differentiate packages by namespace#1713
Conversation
When npm aliases like `npm:@scope/pkg@version` are used, the lockfile v3 `packages` section stores the real package name in a `name` field while the path key uses the alias. The detector now prefers the `name` field over the path-derived name, correctly identifying the real scoped package instead of the alias. Co-authored-by: nickmarston <55464672+nickmarston@users.noreply.github.com>
Co-authored-by: nickmarston <55464672+nickmarston@users.noreply.github.com>
Co-authored-by: nickmarston <55464672+nickmarston@users.noreply.github.com>
In v1/v2 lockfile `dependencies` sections, aliased packages have a version field like `npm:@scope/name@version`. Previously these were silently skipped because the version couldn't be parsed as semver. Add TryParseNpmAlias to extract the real package name and version from this format, and use it in NpmComponentDetectorWithRoots. Co-authored-by: nickmarston <55464672+nickmarston@users.noreply.github.com>
Co-authored-by: nickmarston <55464672+nickmarston@users.noreply.github.com>
Co-authored-by: nickmarston <55464672+nickmarston@users.noreply.github.com>
|
👋 Hi! It looks like you modified some files in the
If none of the above scenarios apply, feel free to ignore this comment 🙂 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Nameproperty toPackageLockV3Packagemodel to capture the real package name for aliased packagesNpmLockfile3Detectorto preferNamefield over path-derived name when availableNameproperty toPackageLockV2Packagemodel for consistencynpm:@namespace/packagename@versionformat in v3 lockfiles (top-level and transitive)TryParseNpmAliasutility method toNpmComponentUtilitiesto parsenpm:@scope/name@versionformat from v1/v2 lockfile version fieldsNpmComponentDetectorWithRootsto useTryParseNpmAliaswhen creating components from v1/v2 lockfiledependenciessectionTryParseNpmAliasinNpmUtilitiesTestsNpmDetectorWithRootsTestsOriginal prompt
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.